lon lat Class
1 -142.9000 61.50000 A
2 -132.7982 55.18720 A
3 -132.8202 55.20350 A
4 -141.5667 62.93750 A
5 -149.7853 61.05950 A
6 -141.3165 62.77335 A
Question 1: What are the environmental conditions that Bigfoot appears to enjoy most?
The conditions that bigfoot likes most are lots of precipitation during the coldest quarter but little precipitation during the driest month.
x <-predict(wc, cart)x <-mask(x, wc[[1]])x <-round(x, 2)plot(x, type="class", plg=list(x="bottomleft"))
set.seed(123)i <-sample(nrow(dw), 0.2*nrow(dw))test <- dw[i,]train <- dw[-i,]fpa <-as.factor(train[, 'pa'])library(randomForest)## randomForest 4.7-1.2## Type rfNews() to see new features/changes/bug fixes.crf <-randomForest(train[, 2:ncol(train)], fpa)crf
Call:
randomForest(x = train[, 2:ncol(train)], y = fpa)
Type of random forest: classification
Number of trees: 500
No. of variables tried at each split: 4
OOB estimate of error rate: 7.19%
Confusion matrix:
0 1 class.error
0 3832 165 0.04128096
1 193 790 0.19633774
Question 2: What did tuneRF help us find? What does the values of mt represent?
tuneRF allows us to find the optival value for mtry, which is the number of variables randomly sampled to use as predictors at each split.
The variable mt is the number of variables to use at each split that minimizes out-of-bag-error. Interestingly, when I run it I get 6 instead of 12 as in the textbook.
Call:
randomForest(x = train[, 2:ncol(train)], y = train[, "pa"], ntree = 250, mtry = mt)
Type of random forest: regression
Number of trees: 250
No. of variables tried at each split: 6
Mean of squared residuals: 0.05436819
% Var explained: 65.68
plot(rrf)
Question 3: What does plot(rrf) show us?
The plot shows us how out of bag error rates decrease as the number of trees are increased. In this case, after about 50 trees the error rates stabilizes, so there is no need to go beyond that.
Question 4: Why would it be that the model does not extrapolate well?
The model does not extrapolate well because the environmental conditions in the eastern US are different from those in the western US and the eastern bigfoot may prefer different environmental conditions to the western bigfoot. Whatever the conditions that the eastern bigfoot prefers, they are not in the training data.
Question 5: What are some countries that should consider Bigfoot as a potential invasive species?
Portugal, Spain, Chile, and Turkey are all good candidates for bigfoot’s next vacation, with potential for Northern China, Mongolia, Morrocco, France, and Greece